<?
// 手机散客预定执行页面
//error_reporting(E_ALL);
require_once("/var/www/html/new/com.inc.php");
include("common/errBack.php");
include("common/err_code.php");
include("class/ProductInfo.php");
include("class/Member.php");
include("class/DisOrder.php");

$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
$memberID=$_REQUEST['did'];
if(!$pid=abs($_REQUEST['pid'])){ getOut("index.html");}
$aid=abs($_REQUEST['aid']);
$pro=new ProductInfo($s,$pid,$aid);
$m=new Member($s,$memberID);
$sOrder=new SaleOrder($s,$pro,$m);


if(p_match($begintime=$_REQUEST['begintime']))  exit("游玩时间含有非法字符");
if(isset($_REQUEST['leavetime'])){
	if(p_match($leavetime=$_REQUEST['leavetime']))  exit("游玩时间含有非法字符");
}
if(p_match($ordername=$_REQUEST['ordername']))  exit("取票人含有非法字符");
if(p_match($ordertel=$_REQUEST['ordertel']))  exit("取票人电话含有非法字符");
if(!$tnum=abs($_REQUEST['tnum']))  exit("门票数不能为零");
if($remoteorder=trim($_REQUEST['remoteorder'])){
	if(p_match($remoteorder)||strlen($remoteorder)>256) exit("远端订单号非法");
}

for($n=1;$n<=$totalTnum;$n++){
	$tourists=array();
	$idcards=array();
	if($_REQUEST['tourist_name_'.$n]||$_REQUEST['tourist_cert_'.$n]){
		$tourists[]=mysql_real_escape_string($_REQUEST['tourist_name_'.$n]);
		$idcards[]=mysql_real_escape_string($_REQUEST['tourist_cert_'.$n]);
	}
}
$option=array();
$option["pid"]=$pid;
$option["begintime"]=$begintime;
$option["leavetime"]=$leavetime;
$option["ordername"]=$ordername;
$option["ordertel"]=$ordertel;
$option["tnum"]=$tnum;
$option["remoteorder"]=$remoteorder;
$option["c_pids"]=unserialize($_REQUEST['c_pids']);
$option["from"]=$_REQUEST['from'];
$option['memo']=mysql_real_escape_string($_REQUEST['memo']);
$option['origin']=$_REQUEST['origin'];
$option['tourists']=$tourists;
$option['idcards']=$idcards;
$option['paymode']= 1;// 支付宝支付
$option['contacttel']=$_REQUEST['contacttel'];

// print_r($option);
// exit;
try{
	$r=$sOrder->order($option);
	$arr = array('s'=>'success','orderid'=>$r);
}catch(DisOrderException $e){
	$arr = array('s'=>'error','msg'=>$e->getMessage());
}catch(InterFaceException $e){
	$arr = array('s'=>'error','msg'=>$e->getMessage()."：".$SoapRequestChk[$e->getCode()]."(".$e->getCode());
}catch(MsgException $e){
	$arr = array('s'=>'error','msg'=>$e->getMessage()."：".telcode($e->getCode())."(".$e->getCode());
}
echo json_encode($arr);
exit;
header("Location:$url");
function getOut($url,$msg=null){
	$js="<script>";
	if($msg){ $js.="alert('$msg');" ;}
	$js.="window.location='$url'</script>";
	exit($js);
}
?>